﻿chrome.browserAction.setTitle({
	title: chrome.i18n.getMessage("extName")
});

if(!localStorage["translate_to"]) {
	chrome.i18n.getAcceptLanguages(function (languages) {
		//console.log(languages);
		localStorage["translate_to"] = languages[0];
	});
}

chrome.browserAction.onClicked.addListener(function (tab) {
	var lang = localStorage["translate_to"];
	chrome.tabs.executeScript(tab.id, {file: 'inject.js'}, function (){});
	chrome.browserAction.setBadgeText({"text": "on", "tabId": tab.id});
});

chrome.extension.onRequest.addListener(
  function(request, sender, sendResponse) {
    //console.log(request.msg);
    sendResponse({lang: localStorage["translate_to"]});
  }
);